<table class="list">
	<tr>
		<th>Date</th>
		<th>Event Type</th>
		<th>Weekly Avg Head Count</th>
	</tr>
	
<% @events = Event.find(:all, :include => :event_type, :conditions => ['event_types.name LIKE ?', 'Celebration Service']) %>
<% @events.group_by {|e| e.date.year_qtr}.sort.each do |g, events| %>

	<tr>
		<td><%= g  rescue nil %></td>
		<td><%= events.first.event_type.name rescue nil %></td>
		<td><%= Contribution.average(events.reject {|i| i.head_count['head_count'].to_i < 1}.collect {|e| e.head_count['head_count'].to_i}) rescue nil %></td>
	</tr>
<% end %>
</table>

<table class ="list">
	<tr><th>&nbsp;</th></tr>
	<tr>
		<td><%= link_to "export stats", :controller => "reports", :action => "export_stats" %></td>
	</tr>
</table>